package recom

import (
	_ "fmt"
	"os"
)
import (
	"buyChance"
	"processes"
	"r_log"
	"tp"
	"util"
)

func initAssigned(length int) []int64 {
	assigned := make([]int64, length)
	return assigned
}

func (r *Recommender) Recommender() {
	for p := util.PERIOD_DAY; p <= util.PERIOD_HHOUR; p++ {
		r.Bcs.BcLock[p].Lock()
		r.Bcs.MfLocks[p].Lock()
		r.Bcs.AssignLevel(p)
		r.Bcs.MfLocks[p].Unlock()
		if len(*r.Tps.PointChanges[p]) > 0 {
			r_log.Logger.Info("recommender: p = %v,acc count= %v ", p, len(*r.Tps.PointChanges[p]))
			r.recommender(p)
		} else {
			r_log.Logger.Info("recommender: no hungery accs, p = %v", p)
		}
		r.Bcs.BcLock[p].Unlock()
	}
}

//在resetBR、filteDuplicateRequirement之后执行
func (r *Recommender) recommender(p util.Period) {
	r_log.RecomLogger.Info("Begin Recom period=%v, caclTime=%v", p, r.Tps.CaclTime)
	defer r_log.RecomLogger.Info("End Recom period=%v, date=%v, caclTime=%v", p, r.Tps.CaclTime)
	ts := r.Tps.CaclTime
	id := util.GeneratorResultID(util.DateAndTime(ts/1000000), util.DateAndTime(ts%1000000), p) //生成初始id
	pcs := r.Tps.PointChanges[p]
	r.Bcs.BuyChances[p].IsValid(r.Tps.CaclTime, true)
	//r.Bcs.BuyChances[p].IsValidTest(r.Tps.CaclTime)
	bcs := r.Bcs.BuyChances[p]
	r_log.Logger.Info("recommender: %v buyChance", len(bcs.BcSlice))
	assigned := initAssigned(len(*pcs)) //用于记录分配到每个账户的股票数量
	requirement := getSumRequirement(pcs)
	var bcsR []*buyChance.BuyChance
	var supply int64
	if requirement == 0 {
		r_log.Logger.Info("No requirement")
		r_log.RecomLogger.Info("No requirement")
		//return
		goto Flag
	}
	pcsSort(pcs)

	//按确认池分配(使用确认池评级时，D级确认池不使用)
	//Flag_UserPool:
	r_log.RecomLogger.Info("Begin user pool")
	for index, pc := range *pcs {
		r_log.TPSLogger.Info("PC[%v](period=%v):  priority=%v, accpetRecom=%v， usepoollvl=%v", index, p, pc.State.Priority, pc.Acc.AcceptRecom, pc.Acc.UsePoolLvl)
		if pc.Acc.Follows == nil {
			r_log.RecomLogger.Info("account's(userid=%v, period=%v) pool is nil", pc.Userid, pc.Period)
			continue
		}
		if pc.Acc.UsePoolLvl && pc.Acc.Follows.Level == util.LEVEL_D {
			r_log.RecomLogger.Info("account's(userid=%v, period=%v) use pool level and level=D", pc.Userid, pc.Period)
			continue
		}
		followsLevel := pc.Acc.Follows.Level
		r_log.RecomLogger.Info("account's(userid=%v, period=%v) pool level=%v", pc.Userid, pc.Period, followsLevel)
		for _, st := range pc.Acc.Follows.Stocks {
			//检查是否已分配足够数量的股票
			if pc.Amount == assigned[index] {
				break
			}
			bc := checkall(bcs, pc, st.Stkid, followsLevel)
			if bc == nil {
				continue
			}
			filtered, mt := bc.CheckType(st.Type, pc.Acc.CdModel, pc.CdOnly)
			if filtered {
				r_log.RecomLogger.Info("stkid(%v): CheckType error: bc.type=%v, types=%v, cdModel=%v, CdOnly=%v", st.Stkid, bc.Type, st.Type, pc.Acc.CdModel, pc.CdOnly)
				continue
			}
			//检查当前是否存在该股票有效的推荐
			r.ResultLock.RLock()
			rrs, ok := r.Results[pc.Userid]
			r.ResultLock.RUnlock()
			if !ok || !rrs.checkDuplicateRecom(st.Stkid) {
				//未发现重复，检查成交额限制，如果符合限制，添加到分配结果中
				if r.addResult(bc.Stkid, bc, pc, util.POPULAR_VeryHot, false, id, id, r.Res.NextMarketDay, ts, mt) {
					assigned[index]++
					id++
					r_log.RecomLogger.Info("stkid(%v): success recom! need=%v, assigned=%v", bc.Stkid, pc.Amount, assigned[index])
				}
			}

		}
	}
	//调配
	//Flag_AcceptRecom:
	r_log.RecomLogger.Info("Begin recom")
	bcsR, supply = getRemainder(bcs)
	if supply == 0 {
		r_log.RecomLogger.Info("Accept recom no enough supply")
		goto Flag
	}
	{
		bcsRlength := len(bcsR)
		for index, pc := range *pcs {
			if !pc.Acc.AcceptRecom {
				r_log.RecomLogger.Info("account's(userid=%v, period=%v) not accept recom", pc.Userid, pc.Period)
				continue
			}
			r_log.RecomLogger.Info("account's(userid=%v, period=%v) begin accept recom", pc.Userid, pc.Period)
			for n := 0; n < bcsRlength; n++ {
				bc := bcsR[n]
				if pc.Amount == assigned[index] {
					break
				}
				if bc.CountinueLose { //调配阶段不对用户分配连续多季度亏损的股票
					continue
				}
				if checkpart(bc, pc, bc.Stkid) {
					continue
				}
				filtered, mt := bc.CheckType(util.MODE_ALL, pc.Acc.CdModel, pc.CdOnly)
				if filtered {
					r_log.RecomLogger.Info("stkid(%v): CheckType error: bc.type=%v, types=%v, cdModel=%v, CdOnly=%v", bc.Stkid, bc.Type, util.MODE_ALL, pc.Acc.CdModel, pc.CdOnly)
					continue
				}
				//检查当前是否存在该股票有效的推荐
				r.ResultLock.RLock()
				rrs, ok := r.Results[pc.Userid]
				r.ResultLock.RUnlock()
				if !ok || !rrs.checkDuplicateRecom(bc.Stkid) {
					//未发现重复，检查成交额限制，如果符合限制，添加到分配结果中
					if r.addResult(bc.Stkid, bc, pc, util.POPULAR_Normal, true, id, id, r.Res.NextMarketDay, ts, mt) {
						assigned[index]++
						id++
						r_log.RecomLogger.Info("stkid(%v): success recom! need=%v, assigned=%v", bc.Stkid, pc.Amount, assigned[index])
					}
				}
			}
		}
	}
	//冗余分配
	//Flag_Redundance:
	r_log.RecomLogger.Info("Begin Redundance")
	bcsR, supply = getRemainder(bcs)
	if supply == 0 {
		r_log.RecomLogger.Info("Redundance no enough supply")
		goto Flag
	}
	{
		bcsRlength := len(bcsR)
		if float64(supply)/float64(requirement) < 1.5 {
			r_log.RecomLogger.Info("Redundance 1.5")
			for index, pc := range *pcs {
				r_log.RecomLogger.Info("account's(userid=%v, period=%v) begin redundance", pc.Userid, pc.Period)
				if assigned[index] < pc.Amount {
					r_log.RecomLogger.Info("amount > assigned, no more stock for user")
					continue
				}
				r.NewRLock.Lock()
				nr, _ := r.NewResults[pc.TPRD.ServerInfo.DataBase]
				r.NewRLock.Unlock()

				popularStocksCount := 0
				popularStocksIds := make([]util.ResultID, 0, assigned[index])
				for _, rr := range *nr {
					if rr.Period != p || rr.UserId != pc.Userid {
						continue
					}
					bc, _ := bcs.BcMap[rr.Stkid]
					if bc.AssignedTransaction*100 > bc.AvgTransaction*util.POPULAR_Hot {
						popularStocksCount++
						popularStocksIds = append(popularStocksIds, rr.GId)
					}
				}

				if pc.Acc.Follows == nil || (pc.Acc.UsePoolLvl && pc.Acc.Follows.Level == util.LEVEL_D) {
					//确认池为空，或者使用确认池评级且评级为D时，不使用确认池
				} else {
					followsLevel := pc.Acc.Follows.Level
					for _, st := range pc.Acc.Follows.Stocks {
						//检查是否已分配足够数量的股票
						if popularStocksCount == 0 {
							break
						}
						bc := checkall(bcs, pc, st.Stkid, followsLevel)
						if bc == nil {
							continue
						}
						filtered, mt := bc.CheckType(st.Type, pc.Acc.CdModel, pc.CdOnly)
						if filtered {
							r_log.RecomLogger.Info("stkid(%v): CheckType error: bc.type=%v, types=%v, cdModel=%v, CdOnly=%v", st.Stkid, bc.Type, st.Type, pc.Acc.CdModel, pc.CdOnly)
							continue
						}
						//检查当前是否存在该股票有效的推荐
						r.ResultLock.RLock()
						rrs, ok := r.Results[pc.Userid]
						r.ResultLock.RUnlock()
						if !ok || !rrs.checkDuplicateRecom(bc.Stkid) {
							//未发现重复，检查成交额限制，如果符合限制，添加到分配结果中
							if r.addResult(bc.Stkid, bc, pc, util.POPULAR_Normal, true, id, popularStocksIds[len(popularStocksIds)-popularStocksCount], r.Res.NextMarketDay, ts, mt) {
								assigned[index]++
								popularStocksCount--
								id++
								r_log.RecomLogger.Info("stkid(%v): success recom! need=%v, assigned=%v", bc.Stkid, pc.Amount, assigned[index])
							}
						}
					}
				}
				if pc.Acc.AcceptRecom {
					for n := 0; n < bcsRlength; n++ {
						bc := bcsR[n]
						if popularStocksCount == 0 {
							break
						}
						if bc.CountinueLose { //冗余分配的调配阶段不对用户分配连续多季度亏损的股票
							continue
						}
						if checkpart(bc, pc, bc.Stkid) {
							continue
						}
						filtered, mt := bc.CheckType(util.MODE_ALL, pc.Acc.CdModel, pc.CdOnly)
						if filtered {
							r_log.RecomLogger.Info("stkid(%v): CheckType error: bc.type=%v, types=%v, cdModel=%v, CdOnly=%v", bc.Stkid, bc.Type, util.MODE_ALL, pc.Acc.CdModel, pc.CdOnly)
							continue
						}
						//检查当前是否存在该股票有效的推荐
						r.ResultLock.RLock()
						rrs, ok := r.Results[pc.Userid]
						r.ResultLock.RUnlock()
						if !ok || !rrs.checkDuplicateRecom(bc.Stkid) {
							//未发现重复，检查成交额限制，如果符合限制，添加到分配结果中
							if r.addResult(bc.Stkid, bc, pc, util.POPULAR_Normal, true, id, popularStocksIds[len(popularStocksIds)-popularStocksCount], r.Res.NextMarketDay, ts, mt) {
								assigned[index]++
								popularStocksCount--
								id++
								r_log.RecomLogger.Info("stkid(%v): success recom by accept recom! need=%v, assigned=%v", bc.Stkid, pc.Amount, assigned[index])
							}
						}
					}
				}
			}
		} else {
			redundance := supply / requirement
			if redundance > 2 {
				redundance = 2
			}
			r_log.RecomLogger.Info("Redundance 2")
			for index, pc := range *pcs {
				r_log.RecomLogger.Info("account's(userid=%v, period=%v) begin redundance", pc.Userid, pc.Period)
				if assigned[index] < pc.Amount {
					r_log.RecomLogger.Info("amount > assigned, no more stock for user")
					continue
				}

				r.NewRLock.Lock()
				nr, _ := r.NewResults[pc.TPRD.ServerInfo.DataBase]
				r.NewRLock.Unlock()

				requireStocksCount := redundance * pc.Amount
				assignedStocksIds := make([]util.ResultID, assigned[index])
				i, j := 0, assigned[index]-1
				for _, rr := range *nr {
					if rr.Period != p || rr.UserId != pc.Userid {
						continue
					}
					bc, _ := bcs.BcMap[rr.Stkid]
					if bc.AssignedTransaction*100 > bc.AvgTransaction*util.POPULAR_Hot { //热门股
						assignedStocksIds[j] = rr.GId
						j--
					} else { //非热门股
						//fmt.Println("111111111", len(assignedStocksIds), i)
						assignedStocksIds[i] = rr.GId
						i++
					}
				}

				if pc.Acc.Follows == nil || (pc.Acc.UsePoolLvl && pc.Acc.Follows.Level == util.LEVEL_D) {
					//确认池为空，或者使用确认池评级且评级为D时，不使用确认池
				} else {
					followsLevel := pc.Acc.Follows.Level
					for _, st := range pc.Acc.Follows.Stocks {
						//检查是否已分配足够数量的股票
						if requireStocksCount == 0 {
							break
						}
						bc := checkall(bcs, pc, st.Stkid, followsLevel)
						if bc == nil {
							continue
						}
						filtered, mt := bc.CheckType(st.Type, pc.Acc.CdModel, pc.CdOnly)
						if filtered {
							r_log.RecomLogger.Info("stkid(%v): CheckType error: bc.type=%v, types=%v, cdModel=%v, CdOnly=%v", st.Stkid, bc.Type, st.Type, pc.Acc.CdModel, pc.CdOnly)
							continue
						}
						//检查当前是否存在该股票有效的推荐
						r.ResultLock.RLock()
						rrs, ok := r.Results[pc.Userid]
						r.ResultLock.RUnlock()
						if !ok || !rrs.checkDuplicateRecom(bc.Stkid) {
							//未发现重复，检查成交额限制，如果符合限制，添加到分配结果中
							if r.addResult(bc.Stkid, bc, pc, util.POPULAR_Normal, true, id, assignedStocksIds[(requireStocksCount-1)%pc.Amount], r.Res.NextMarketDay, ts, mt) {
								assigned[index]++
								requireStocksCount--
								id++
								r_log.RecomLogger.Info("stkid(%v): success recom in user pool! need=%v, assigned=%v", bc.Stkid, pc.Amount, assigned[index])
							}
						}
					}
				}
				if pc.Acc.AcceptRecom {
					for n := 0; n < bcsRlength; n++ {
						bc := bcsR[n]
						if requireStocksCount == 0 {
							break
						}
						if bc.CountinueLose { //冗余分配的调配阶段不对用户分配连续多季度亏损的股票
							continue
						}
						if checkpart(bc, pc, bc.Stkid) {
							continue
						}
						filtered, mt := bc.CheckType(util.MODE_ALL, pc.Acc.CdModel, pc.CdOnly)
						if filtered {
							r_log.RecomLogger.Info("stkid(%v): CheckType error: bc.type=%v, types=%v, cdModel=%v, CdOnly=%v", bc.Stkid, bc.Type, util.MODE_ALL, pc.Acc.CdModel, pc.CdOnly)
							continue
						}
						//检查当前是否存在该股票有效的推荐
						r.ResultLock.RLock()
						rrs, ok := r.Results[pc.Userid]
						r.ResultLock.RUnlock()
						if !ok || !rrs.checkDuplicateRecom(bc.Stkid) {
							//未发现重复，检查成交额限制，如果符合限制，添加到分配结果中
							if r.addResult(bc.Stkid, bc, pc, util.POPULAR_Normal, true, id, assignedStocksIds[(requireStocksCount-1)%pc.Amount], r.Res.NextMarketDay, ts, mt) {
								assigned[index]++
								requireStocksCount--
								id++
								r_log.RecomLogger.Info("stkid(%v): success recom by accept recom! need=%v, assigned=%v", bc.Stkid, pc.Amount, assigned[index])
							}
						}
					}
				}
			}

		}
	}
	//Flag_End:
Flag:
	for index, pc := range *pcs {
		pc.UpdatePriority(pc.Amount, assigned[index])
		if assigned[index] > 0 {
			r.Statistic[p].CountOfGetStock++
		} else {
			r.Statistic[p].CountOfNotGetStock++
		}
		nri, ok := r.NewRInfos[pc.TPRD.ServerInfo.DataBase]
		if !ok {
			nri = &[]RecommenderResultInfo{}
			r.NewRInfos[pc.TPRD.ServerInfo.DataBase] = nri
		}

		info := RI_HaveRecomm
		if assigned[index] == 0 {
			if pc.Amount == 0 {
				info = RI_NOPosition
			} else {
				info = RI_NORecomm
			}
		}

		ri := RecommenderResultInfo{
			UserId:    pc.Userid,
			Period:    pc.Period,
			FlowId:    pc.Flowid,
			TimeStamp: r.Tps.CaclTime,
			Info:      info,
			Date:      r.Tps.Date,
			Batch:     r.Tps.Batch[p]}
		*nri = append(*nri, ri)
	}
}

//standard: 预计成交额可分配的上限百分比，例如30表示只要已分配的成交额不超过预计成交额的30%就可以继续推荐
func (r *Recommender) addResult(stkid util.StkID, bc *buyChance.BuyChance, pc tp.PointChange,
	standard int64, checkMaxAmount bool, rid, gid util.ResultID, nmd util.DateAndTime, ts util.TimeStamp, mt util.ModeType) bool {
	//检查预警信号的预计成交额和价格是否不匹配用户需求

	if pc.Acc.OneYearLoss {
		if bc.IsInChooseMap {
			r_log.RecomLogger.Info("stkid(%v): Continue Loss In Last 1 Year", stkid)
			return false
		}
	}

	//methodType := util.GetMethodType(pc.Acc.ParentAcc.Version)
	methodType, methodstyle := util.GetMethodType_New(pc.MethodType, pc.MethodStyle)
	priceStandard := int64((float64(bc.Price[0]) * 1.02) + 0.5)
	//mr, expectCapital := processes.GetMethodResult(pc.MethodStyle, methodType, bc.NProfitRate, bc.NMaxLoss, bc.NSuccRate, priceStandard, pc.Capital)
	mr, expectCapital := processes.GetMethodResult(methodstyle, methodType, bc.NProfitRate, bc.NMaxLoss, bc.NSuccRate, priceStandard, pc.Capital)
	if expectCapital == 0 { //预估资金量，可用于判断根据打法是否能够生成加仓策略，==0时即未生成有效的加仓策略
		r_log.RecomLogger.Info("stkid(%v): get method result faild, expectCapital is 0", stkid)
		return false
	}
	bc.Lock.Lock()
	//capital int64, prices []int64, capitals []int64, standard int64, checkMaxAmount bool, p util.Period, isSAcc bool
	if bc.CheckAmount(pc.Capital, mr.Prices, mr.Capitals, standard, checkMaxAmount, pc.Period, pc.Acc.ParentAcc.IsSAcc) {
		bc.Lock.Unlock()
		r_log.RecomLogger.Info("stkid(%v): not enough amount", stkid)
		return false
	} else {
		if pc.Acc.ParentAcc.IsSAcc {
			bc.AssignedCount += 1
		} else {
			bc.AssignedTransaction += pc.Capital
		}
	}
	bc.Lock.Unlock()
	rr := RecommenderResult{
		UserId:   pc.Userid,
		Period:   pc.Period,
		FlowId:   pc.Flowid,
		Date:     bc.Date,
		Time:     bc.Time,
		LastDate: r.Res.LastValidDay,
		Batch:    r.Tps.Batch[pc.Period],
		Stkid:    stkid,
		Type:     chooseModeType(mt),
		//MethodStyle:  pc.MethodStyle,
		MethodStyle:  methodstyle,
		Capital:      pc.Capital,
		Price0:       bc.Price[0],
		Price1:       priceReset(bc.Price[0], bc.Price[1]),
		Price2:       priceReset(bc.Price[0], bc.Price[2]),
		Price3:       priceReset(bc.Price[0], bc.Price[3]),
		Price4:       priceReset(bc.Price[0], bc.Price[4]),
		Price5:       priceReset(bc.Price[0], bc.Price[5]),
		Capital1st:   0, //首仓限额（如果只有一仓则填0）
		Capital2nd:   0, //2仓限额（如果只有一或两仓则填0）
		Price2nd:     0, //2仓下调点位（万分之）（如果只有一仓则填0）
		Price3rd:     0, //3仓下调点位（万分之）（如果只有一或两仓则填0）
		RId:          rid,
		GId:          gid,
		MarketSector: util.MarketCode(0), //股票所属板块功能暂未添加
		TimeStamp:    ts}
	if len(mr.Capitals) > 1 {
		rr.Capital1st = mr.Capitals[0]
		rr.Price2nd = mr.Pos[1]
	}
	if len(mr.Capitals) > 2 {
		rr.Capital2nd = mr.Capitals[1]
		rr.Price3rd = mr.Pos[2]
	}
	if bc.Time >= 150000 {
		rr.Date = nmd
		rr.Time = 93000
	}

	r.ResultLock.Lock()
	rrs, ok := r.Results[pc.Userid]
	if !ok {
		rrs = new(RecommenderResultsInOneDay)
		*rrs = make(RecommenderResultsInOneDay)
		r.Results[pc.Userid] = rrs
	}
	(*rrs)[stkid] = pc.Period
	r.ResultLock.Unlock()

	r.NewRLock.Lock()
	nr, ok := r.NewResults[pc.TPRD.ServerInfo.DataBase]
	if !ok {
		nr = &[]RecommenderResult{}
		r.NewResults[pc.TPRD.ServerInfo.DataBase] = nr
	}
	*nr = append(*nr, rr)
	r.NewRLock.Unlock()
	return true
}

func priceReset(price0, priceX int32) int32 {
	if priceX == 0 {
		return price0
	}
	return priceX
}

func getSumRequirement(pcs *[]tp.PointChange) int64 {
	var re int64 = 0
	for _, pc := range *pcs {
		re += pc.Capital * pc.Amount
	}
	return re
}

func getRemainder(bcs *buyChance.BuyChances) ([]*buyChance.BuyChance, int64) {
	rebcs := make([]*buyChance.BuyChance, 0)
	var re int64 = 0
	for _, bc := range bcs.BcSlice {
		if bc.AssignedTransaction*100 < bc.AvgTransaction*util.POPULAR_Normal {
			rebcs = append(rebcs, bc)
			re += bc.AvgTransaction*util.POPULAR_Normal/100 - bc.AssignedTransaction
		}
	}
	return rebcs, re
}

func checkFileIsExist(filename string) bool {
	var exist = true
	if _, err := os.Stat(filename); os.IsNotExist(err) {
		exist = false
	}
	return exist
}

func (r *Recommender) UpdateLastCalcPiont() error {
	var f *os.File
	var err error
	if checkFileIsExist("../../savefile/LastCalcPoint") { //如果文件存
		os.Remove("../../savefile/LastCalcPoint")          //打开文件
		f, err = os.Create("../../savefile/LastCalcPoint") //打开文件
	} else {
		f, err = os.Create("../../savefile/LastCalcPoint") //创建文件
	}
	if err != nil {
		return err
	}
	defer f.Close()
	b := util.Uint64ToByte(uint64(r.LastCalcPoint))
	f.Write(b)
	return nil
}

//当同一个出击点多个模型出击的时候，优先认震荡、牛头、超跌
func chooseModeType(types util.ModeType) util.ModeType {
	switch {
	case types&util.MODE_ZHENDANG > 0:
		return util.MODE_ZHENDANG
	case types&util.MODE_NIUTOU > 0:
		return util.MODE_NIUTOU
	case types&util.MODE_CHAODIE > 0:
		return util.MODE_CHAODIE
	default:
		return util.MODE_QUSHI
	}
}

func (r *Recommender) ResetStatistic(calcPoint util.TimeStamp) {
	time := calcPoint % 1000000
	for p := util.PERIOD_DAY; p < util.PERIOD_COUNT; p++ {
		switch p {
		case util.PERIOD_DAY:
			switch time {
			case util.TimeStamp(220000):
				r.Statistic[p].CountOfGetStock = 0
				r.Statistic[p].CountOfNotGetStock = 0
			}
		case util.PERIOD_2HOUR:
			switch time {
			case util.TimeStamp(123000), util.TimeStamp(220000):
				r.Statistic[p].CountOfGetStock = 0
				r.Statistic[p].CountOfNotGetStock = 0
			}
		case util.PERIOD_HOUR:
			switch time {
			case util.TimeStamp(103000), util.TimeStamp(123000), util.TimeStamp(140000), util.TimeStamp(220000):
				r.Statistic[p].CountOfGetStock = 0
				r.Statistic[p].CountOfNotGetStock = 0
			}
		case util.PERIOD_HHOUR:
			switch time {
			case util.TimeStamp(100000), util.TimeStamp(103000), util.TimeStamp(110000), util.TimeStamp(123000), util.TimeStamp(133000), util.TimeStamp(140000), util.TimeStamp(143000), util.TimeStamp(220000):
				r.Statistic[p].CountOfGetStock = 0
				r.Statistic[p].CountOfNotGetStock = 0
			}
		}
	}
}

type StatisticsSave struct {
	Date               int
	Period             int
	CountOfGetStock    int
	CountOfNotGetStock int
	CountOfBuyChance   int
}
